CONTENTS | INDEX | PREV | NEXT
fputs
puts
NAME
fputs - write a string to a file pointer
puts - write a string to stdout and also write a newline
SYNOPSIS
#include <stdio.h>
int error = fputs(s, fp);
int error = puts(s);
const char *s;
FILE *fp;
FUNCTION
fputs writes a string to a file pointer all the way up to, but not
including, the nul. puts does the same thing but to stdout, and
puts additionally writes a newline out.
NOTE
refer to the file_pointer manual page for general information
It is common to get confused between fputs and puts. Remember that
puts adds a newline to the output while fputs does not. gets strips
the newline from an input line while fgets does not.
EXAMPLE
#include <stdio.h>
main()
{
fputs("This is a test of fputsn", stdout); /* note newline */
puts("This is a test of puts"); /* note lack of */
puts("That's it!");
return(0);
}
INPUTS
char *s; string to write
FILE *fp; file pointer
RESULTS
int error; 0 or positive if all went ok, else negative. Note
that unlike *printf() routines the number of chars
written out is NOT returned.
SEE ALSO
getc, putc, fputc, fread, fwrite, gets, fgets